<!--菜单栏页面-->
<template>
  <div id="memu_bar">
    <Hander></Hander>
    <!--菜单栏部分-->
    <section class="main-container col2-left-layout">
      <div class="container">
        <div class="row">
          <!--右边个人信息-->
          <div class="col-sm-9 col-sm-push-3">
            <router-view/>
          </div>
          <!--菜单栏部分-->
          <aside class="col-left sidebar col-sm-3 col-xs-12 col-sm-pull-9">
            <div class="block block-account">
              <div class="block-title">我的帐户</div>
                  <el-col>
                    <el-menu
                      :default-active="activeMenu"
                      class="el-menu-vertical-demo">
                      <el-submenu :index="item.permissionCode+''" v-for="(item,index) in menuList"
                      :key="item.menu.permissionId">
                        <template slot="title">
                          <i class="el-icon-location"></i>
                          <span @click="routers(i.permissionPath)">{{ item.menu.permissionName }}</span>
                        </template>
                        <el-menu-item-group>
                          <el-menu-item :index="i.permissionCode+''" @click="routers(i.permissionPath);saveActive(i.permissionCode)+''" v-for="(i,idaex) in item.submemu" :key="i.permissionId">
                            {{ i.permissionName }}
                          </el-menu-item>
                        </el-menu-item-group>
                      </el-submenu>
                    </el-menu>
                  </el-col>


            </div>
          </aside>
        </div>
      </div>
    </section>
  </div>
</template>

<script>
import Hander from "./Hander"
// let arrays;
export default {
  name: "MemuBar",
  data(){
    return{
      menuList:[],
      activeMenu:''
    }
  },
  methods:{
    getMenuList(){
      var staffemail;
      if (this.$store.getters.getStaff.staffEmail == null){
        staffemail='';
      }else {
        staffemail = this.$store.getters.getStaff.staffEmail;
      }
      this.$axios.get("/staff/getMemuList?staffEmail="+staffemail,{
        headers:{
          "Authrization":this.$store.getters.getToken
        },
      }).then(
        res =>{
          // console.log(res.data.data)
          this.menuList = res.data.data
        }
      )

    },
    routers(x){
      this.$router.push(x)
    },
    saveActive(val){
      this.active = val;
      localStorage.setItem("activeMenu",val);
    }
  },created() {
    this.getMenuList()
    this.active = localStorage.getItem("activeMenu")
  },
  components:{
    Hander,
  }
}
</script>

<style scoped>

</style>
